import 'package:flame/components.dart';

import 'bird.dart';

class StartButtonComponent extends SpriteComponent {
  StartButtonComponent(this.screenSize, this.birdComponent)
      : super(size: Vector2(116, 70));

  Vector2 screenSize;
  final BirdComponent birdComponent;

  @override
  Future<void>? onLoad() async {
    sprite = await Sprite.load('button_play.png');
  }

  @override
  void onGameResize(Vector2 size) {
    super.onGameResize(size);
    screenSize = size;
    position = Vector2((size.x - 116) / 2, (size.y - 96) - 70 - 20);
  }

  @override
  void update(double dt) {
    super.update(dt);
    if (birdComponent.getCurrentStatus() == BirdComponent.statusFlying) {
      removeFromParent();
    }
  }
}
